package com.tide.crm.dao;

import java.util.List;
import java.util.Map;

import com.tide.crm.model.ConvergeUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


@Mapper
public interface ConvergeUserDao {

    @Select("select * from converge_user t where t.id = #{id}")
    ConvergeUser getById(Long id);
    
    @Select("select * from converge_user t where t.LOGIN_NAME = #{loginName}")
    ConvergeUser getUser(String loginName);

    @Delete("delete from converge_user where id = #{id}")
    int delete(Long id);

    int update(ConvergeUser convergeUser);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into converge_user(ID, CREATE_DATE, MODIFY_DATE, LOGIN_NAME, USER_NAME, IDCARD, FACE_IDCARD, BACK_IDCARD, IS_CERTIFICATION, PASSWORD, WECHATID, USER_TYPE, CONTACT_NUMBER) values(#{id}, #{createDate}, #{modifyDate}, #{loginName}, #{userName}, #{idCard}, #{FaceIdCard}, #{BackIdCard}, #{isCertification}, #{passWord}, #{wechatId}, #{userType}, #{contactNumber})")
    int save(ConvergeUser convergeUser);
    
    int count(@Param("params") Map<String, Object> params);

    List<ConvergeUser> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
